<template>
  <div id="app">
    <input type="text" v-model.number.lazy="count" placeholder="请输入大于1的值">
    <strong class="count" @click="add">
      {{count}}
    </strong>
    <button @click="asyncAdd">async 2s</button>
  </div>
</template>

<script>
  export default {
    name: 'App',
    computed:{
      count:{
        get(){return this.$store.state.count},
        set(count){
          // this.$store.dispatch("add",{count})
          if(count>1){
            this.$store.dispatch({
              type:"add",
              count
            })
          }
        }
      }
    },
    methods:{
      add(){
        this.$store.dispatch("add")
      },
      asyncAdd(){
        this.$store.dispatch("asyncAdd")
      }
    }
  }
</script>

<style scoped>
  .count{
    display: block;
    width: 100px;
    height: 100px;
    background: pink;
    border-radius: 50%;
    text-align: center;
    line-height: 100px;
    font-size: 30px;
  }
</style>
